package kd.hc.utils;

import kd.bos.entity.datamodel.IBillModel;
import kd.bos.entity.datamodel.IDataModel;
import kd.bos.form.CloseCallBack;
import kd.bos.form.FormShowParameter;
import kd.bos.form.IFormView;
import kd.bos.form.ShowType;
import kd.bos.list.ListShowParameter;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;

import java.util.ArrayList;
import java.util.List;

public class ShowParameterUtil {

    public static void billInContainerList(IFormView view, IDataModel dataModel, String billFormId, String targetKey, Boolean hideToolBarap, Boolean hideFilterContainerap, List<QFilter> allFilters) {
        ListShowParameter listShowParameter = new ListShowParameter();
        listShowParameter.setFormId("bos_list");
//        listShowParameter.setLookUp(true);
        listShowParameter.setShowFilter(false);
        listShowParameter.setShowTitle(false);
        listShowParameter.setMultiSelect(false);
        listShowParameter.setShowQuickFilter(false);
        listShowParameter.getListFilterParameter().setQFilters(allFilters);
        listShowParameter.setBillFormId(billFormId);
        listShowParameter.setCustomParam("hideToolBarap", hideToolBarap);
        listShowParameter.setCustomParam("hideFilterContainerap", hideFilterContainerap);
        listShowParameter.getOpenStyle().setShowType(ShowType.InContainer);
        listShowParameter.getOpenStyle().setTargetKey(targetKey);
        view.showForm(listShowParameter);
    }

    public static void billInContainerList(IFormView view, IDataModel dataModel, String billFormId, String targetKey, List<QFilter> allFilters) {
        billInContainerList(view, dataModel, billFormId, targetKey, true, true, allFilters);
    }

    public static void billInContainerList(IFormView view, IDataModel dataModel, String billFormId, String targetKey, String key, Object value) {
        List<QFilter> allFilters = new ArrayList<QFilter>();
        QFilter qFilter = new QFilter(key, QCP.equals, value);
        allFilters.add(qFilter);
        billInContainerList(view, dataModel, billFormId, targetKey, allFilters);
    }

    public static void contractbillInContainerList(IFormView view, IDataModel dataModel, String billFormId, String targetKey, Object value) {
        billInContainerList(view, dataModel, billFormId, targetKey, "contract.id", value);
    }

    public static void contractbillInContainerList(String title, IFormView view, IDataModel dataModel, String billFormId, String targetKey, Object value) {
        contractbillInContainerList(view, dataModel, billFormId, targetKey, value);
    }

    public static void showFormShowParameter(String title, IFormView view, IDataModel dataModel, String formId, ShowType showType, CloseCallBack closeCallBack) {
        FormShowParameter showParameter = new FormShowParameter();
        showParameter.setFormId(formId);
        showParameter.setCaption(title);
        showParameter.setCustomParam("formTitle", title);
        showParameter.getOpenStyle().setShowType(showType);
        showParameter.setCloseCallBack(closeCallBack);
        view.showForm(showParameter);
    }


}
